package com.hzcx.app.simplechat.ui.friend.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.ui.friend.bean.FriendRequestBean;
import com.hzcx.app.simplechat.util.glide.GlideUtils;

import java.util.List;

public class FriendRequestContentAdapter extends BaseQuickAdapter<FriendRequestBean.OneDataBean, BaseViewHolder> {
    public FriendRequestContentAdapter(@Nullable List<FriendRequestBean.OneDataBean> data) {
        super(R.layout.rv_item_friend_request_content,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FriendRequestBean.OneDataBean item) {
        GlideUtils.loadImg(mContext,item.getAvatar(),helper.getView(R.id.iv_head));
        helper.setText(R.id.tv_nick_name,item.getNickname());
        helper.setText(R.id.tv_remark,item.getDescription());

        switch (item.getState()){
            case 0: // 申请中
                helper.setVisible(R.id.btn_send,true);
                helper.setVisible(R.id.tv_state,false);
                break;

            case -1: // 已拒绝
                helper.setVisible(R.id.btn_send,false);
                helper.setVisible(R.id.tv_state,true);
                helper.setText(R.id.tv_state,"已拒绝");
                break;

            case 1: // 已添加
                helper.setVisible(R.id.btn_send,false);
                helper.setVisible(R.id.tv_state,true);
                helper.setText(R.id.tv_state,"已添加");
                break;

            case -2: // 已过期
                helper.setVisible(R.id.btn_send,false);
                helper.setVisible(R.id.tv_state,true);
                helper.setText(R.id.tv_state,"已过期");
                break;
        }

        helper.addOnClickListener(R.id.btn_send);
    }
}
